py_dir="$2"
dir_name="$(dirname $1)"
file_name="$(echo $1 |  sed 's/^\(.*\/\)*\(.*\)/\2/; s/\.i//' )"

cd $dir_name

new_file="${file_name}$3"
cat $file_name.i | sed "1s/^/%module xrnlib$3 /" > $new_file.i

swig -lcpointer.i  -lcarrays.i   -lcmalloc.i  -lstdint.i  -python -DXNBITS=$3 $new_file.i

echo "#endif" >> "${new_file}_wrap.c"
sed -i '1s/^/#if ( SWIGPYTHONEN == 1 ) \n/' "${new_file}_wrap.c"

mv "${new_file}.py" $py_dir




